//
//  GroupInfoView.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/12.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "GroupInfoView.h"

@implementation GroupInfoView

#pragma mark --- 懒加载
- (UICollectionView *)collectionView{
    if (!_collectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(px1080Width(1000)/4 - 8 , px1920Height(601)/2 - 4);
        layout.minimumLineSpacing = 0;
        layout.minimumInteritemSpacing = 0;
        layout.sectionInset = UIEdgeInsetsMake(6, 6, 6, 6);
        _collectionView = ({
            UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
            collectionView.scrollEnabled = NO;
            collectionView.backgroundColor = [UIColor clearColor];
            [self addSubview:collectionView];
            collectionView;
        });
        
        
        
    }return _collectionView;
}
- (UIButton *)moreButton
{
    if(!_moreButton)
    {
        UIView *superView = self;
        _moreButton = [[UIButton alloc]init];
        [superView addSubview:_moreButton];
        [_moreButton setTitle:@"查看更多群成员" forState:UIControlStateNormal];
        [_moreButton setImage:imageWithName(@"right") forState:UIControlStateNormal];
        [_moreButton setTitleColor:rgba(255,255,255,0.79) forState:UIControlStateNormal];
        [_moreButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:0];
        [_moreButton.titleLabel setFont:fontCommonSize];
    }
    return _moreButton;
}

- (UITableView *)tableView
{
    if(!_tableView)
    {
        UIView *superView = self;
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleGrouped];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.scrollEnabled = NO;
        [superView addSubview:_tableView];
        _tableView.backgroundColor = [UIColor clearColor];
    }
    return _tableView;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    UIView *bgView = [[UIView alloc] init];
    [superView addSubview:bgView];
    bgView.backgroundColor = rgba(27,44,81,1);
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(90));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(px1080Width(1000), px1920Height(751)));
    }];
    
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(bgView);
        make.height.mas_equalTo(px1920Height(600));
    }];
    
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.collectionView.mas_bottom).with.offset(px1920Height(50));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.width.mas_equalTo(200);
    }];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(bgView.mas_bottom).with.offset(px1920Height(30));
        make.left.right.mas_equalTo(bgView);
        make.bottom.mas_equalTo(superView.mas_bottom);
    }];
}

@end
